
from flask import Flask, jsonify
from service.bar import getRewardAndLevelService, getParticipateService, getRewardCntService
from service.pie import getComTypeCntService
from service.table import getCoorCntService
from service.wordCloud import wordCloudUnitService, wordCloudProjectService



app = Flask(__name__)



@app.route('/')
def index():
    # return render_template('snake.html')
    return "我们的科技奖励平台后台"

"""
绘制完成单位云图
params:province
return json-dict
"""
@app.route('/wordCloud/unit/<province>',methods={'GET'})
def wordCloudUnit(province):

    data=wordCloudUnitService(province)
    return jsonify(data)
"""
绘制项目名称词云图
params:province
return json-dict
"""
@app.route('/wordCloud/project/<province>',methods={'GET'})
def wordCloudProject(province):
    data=wordCloudProjectService(province)
    return jsonify(data)
"""
绘制获奖等级柱状图
params:province
return json-dict
"""
@app.route('/bar/rewardlevel/<province>',methods={'GET'})
def rewardLevel(province):
    data=getRewardAndLevelService(province)
    return jsonify(data)
"""
绘制参与项目数最多的15个单位的参与次数柱形图
params:province
return json-list-dict-(str:list)
"""
@app.route('/bar/participate/<province>',methods={'GET'})
def participate(province):
    data=getParticipateService(province)
    return jsonify(data)
"""
绘制各种奖项的年获奖总数
params:province
return json-list-dict-(str:list)
"""
@app.route('/bar/rewardcount/<province>',methods={'GET'})
def rewardCnt(province):
    data=getRewardCntService(province)
    return jsonify(data)

"""
合作次数最多的单位对
params:province
return json-list-dict
"""
@app.route('/table/coor/<province>',methods={'GET'})
def coor(province):
    data=getCoorCntService(province)
    return jsonify(data)
"""
完成单位类型占比图
params:province
return json-dict-list-dict
"""
@app.route('/pie/comTypeCnt/<province>',methods={'GET'})
def comTypeCnt(province):
    data=getComTypeCntService(province)
    return jsonify(data)


#启动入口
if __name__ == "__main__":#TODO 启动按钮
    # app.run(host='0.0.0.0')#局域网公开访问
    app.run(debug=False)
    # debug==True是为了方便修改代码之后，能够不重启项目就能够更新，否则，每次更改代码都需要重新启动项目
    # 其他参数的设置可以查阅文档，这里越简单越好